class Orgs
  attr_accessor :github, :members, :teams

  def initialize(github)
    @github = github
    @members = OrgsMembers.new(github)
    @teams = OrgsTeams.new(github)
  end

  def listOrgs(user=nil)
    username = user == nil ? @github.username : user
    url = user != @github.username ? 'users/%s/orgs' % username : 'user/orgs'
    @github.get(url)
  end

  def getOrg(org)
    @github.get('orgs/%s' % org)
  end

  def editOrg(org, billing_email=nil, company=nil, email=nil, location=nil, name=nil)
    params = {
        :billing_email => billing_email,
        :company => company,
        :email => email,
        :location => location,
        :name => name
    }
    params = @github.removeEmptyParams(params)
    data = params.to_json
    @github.patch('org/%s' % org, data)
  end
end